<?php
/**
 * iZAP izap_videos
 *
 * @package Elgg videotizer, by iZAP Web Solutions.
 * @license GNU Public License version 3
 * @Contact iZAP Team "<support@izap.in>"
 * @Founder Tarun Jangra "<tarun@izap.in>"
 * @link http://www.izap.in/
 * @version 3.8b
 */

gatekeeper();

$user_guid = get_loggedin_userid();
$video = get_entity(get_input('guid', 0));

if(get_input('izap_action', FALSE) == 'remove'){
  izap_remove_favorited($video);
  system_message(video_echo('favorite_removed'));
}else if($video instanceof IzapVideos) {
  izapGetAccess_izap_videos();
  $old_array = $video->favorited_by;
  $new_array = array_merge((array) $old_array, (array) $user_guid);
  $video->favorited_by = array_unique($new_array);
  izapRemoveAccess_izap_videos();
  system_message(video_echo('favorite_saved'));
}
forward($_SERVER['HTTP_REFERER']);
exit;

